package com.youbug.mall.product_pms.controller;


import com.youbug.common.vo.QueryVo;
import com.youbug.mall.product_pms.entity.PmsAttr;
import com.youbug.mall.product_pms.service.IPmsAttrService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 商品属性 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-04-09
 */
@RestController
@RequestMapping("/pmsAttr")
public class PmsAttrController {
    @Autowired
    private IPmsAttrService pmsAttrService;

    @PostMapping("/getPmsAttrPage")
    public R<IPage<PmsAttr>> getPmsAttrPage(@RequestBody QueryVo<PmsAttr> queryVo){

        IPage<PmsAttr> pmsAttrs = pmsAttrService.getPmsAttrPage(queryVo);

        return R.ok(pmsAttrs);
    }

    @GetMapping("/getPmsAttrById/{id}")
    public R<PmsAttr> getPmsAttrById(@PathVariable Integer id){

        PmsAttr pmsAttr = pmsAttrService.getPmsAttrById(id);

        return R.ok(pmsAttr);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody PmsAttr pmsAttr){

        boolean save = pmsAttrService.saveAttr(pmsAttr);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody PmsAttr pmsAttr){

        boolean update = pmsAttrService.updatePmsAttrById(pmsAttr);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = pmsAttrService.removePmsAttrById(id);

        return  R.ok(remove);
    }
}

